<?php

namespace app\shop\controller\product;

use app\Request;
use app\shop\controller\Controller;
use app\shop\model\product\ProductBrandRelationModel;

/**
 * 用户管理
 */
class ProductRelationBrand extends Controller
{
    /**
     * 商户列表
     */
    public function index(Request $request)
    {
        $where = $request->param();
        $list = ProductBrandRelationModel::listData($where, $this->getData(), []);
        return $this->renderSuccess('', compact('list'));
    }

    public function create(Request $request)
    {
        try {
            $where = $request->param();
            // 新增记录
            $result = ProductBrandRelationModel::createData($where);
            return $this->renderSuccess('操作成功', $result);
        } catch (\Exception $exception) {
            return $this->renderError($exception->getMessage());
        }
    }

    public function edit(Request $request)
    {
        $where = $request->param();
        // 用户详情
        $model = ProductBrandRelationModel::one($where);
        return $this->renderSuccess('', compact('model'));

    }

    public function update(Request $request)
    {
        $params = $request->param();
        // 修改记录
        BrandModel::update($params);
        return $this->renderSuccess('修改成功');
    }

    public function delete(Request $request)
    {
        $params = $request->param();
        // 修改记录
        ProductBrandRelationModel::deleteData($params);
        return $this->renderSuccess('删除成功');
    }
}
